package com.pym.bs.controller;

import com.pym.bs.domain.Ldemo;
import com.pym.bs.dto.DemosDTO;
import com.pym.bs.dto.LdemoDTO;
import com.pym.bs.service.LdemoService;
import com.pym.bs.utils.Pageable;
import com.pym.bs.utils.ResultVOUtils;
import com.pym.bs.vo.PageVO;
import com.pym.bs.vo.ResultVO;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

@RestController
@RequestMapping(value = "api/ldemo")
public class LdemoController {

    @Resource
    private LdemoService ldemoService;

    @RequestMapping(value = "/add")
    public ResultVO<Ldemo> add(@RequestBody LdemoDTO ldemoDTO) throws IOException {
        return ldemoService.save(ldemoDTO);
    }

    @RequestMapping(value = "/list")
    public ResultVO<LdemoDTO> list(LdemoDTO ldemoDTO, Pageable pageable) {
        PageVO<DemosDTO> list = ldemoService.list(ldemoDTO, pageable);
        return ResultVOUtils.success(list);
    }
}
